import {ADD_CURRENT_MENU, REMOVE_CURRENT_MENU, CLEAR_CURRENT_MENUS, SET_AUTHORIZED_MENU, SET_AUTHORIZED_MENU_FUNCTION} from "../mutationTypes"

const state = {
  /*  当前选中的菜单  */
  currentMenus: [],

  /* 当前用户的所有Menu */
  authorizedMenu:[],

  /* 菜单下授权的功能 */
  authorizedMenuFunction:[]
};

const mutations = {
  /*  增加当前选中的菜单  */
  [ADD_CURRENT_MENU](state, menu) {
    state.currentMenus.push(menu);
  },
  /*  清空当前选中的所有菜单  */
  [CLEAR_CURRENT_MENUS](state) {
    state.currentMenus = [];
  },
  /* 移除指定菜单 */
  [REMOVE_CURRENT_MENU](state, menu) {
    state.currentMenus.splice(state.currentMenus.indexOf(menu), 1);
  },
  /* 授权的菜单 */
  [SET_AUTHORIZED_MENU](state, authorizedMenu) {
    state.authorizedMenu = authorizedMenu;
  },
  /* 授权的功能 */
  [SET_AUTHORIZED_MENU_FUNCTION](state, authorizedMenuFunction) {
    state.authorizedMenuFunction = authorizedMenuFunction;
  }
};

export default {
  state,
  mutations
}



// WEBPACK FOOTER //
// ./src/store/modules/Menu.js